package com.sh.common.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum UserFoundEnum {

    /**
     * 购买算力
     */
    PURCHASE_COMPUTILITY(0, "购买算力"),
    /**
     * 节点算力（永久算力、临时算力）
     */
    COMPUTILITY(1, "算力"),

    /**
     * usdt
     */
    USDT(2, "usdt"),

    /**
     * aleo
     */
    ALEO(3, "aleo"),

    /**
     * scr
     */
    SCR(10, "scr"),

    /**
     * repurchase_usdt
     */
    REPURCHASE_USDT(12, "repurchase_usdt"),

    /**
     * 本人业绩
     */
    SELF_ACHIEVEMENT(4, "本人业绩"),

    /**
     * 团队业绩
     */
    TEAM_ACHIEVEMENT(5, "团队业绩"),

    /**
     * 直推业绩
     */
    DIRECT_PUSH_ACHIEVEMENT(6, "直推业绩"),

    /**
     * 可用SZPN
     */
    AVAILABLE_SZPN(20, "可用SZPN"),

    /**
     * 锁仓szpn
     */
    FREEZE_SZPN(30, "锁仓szpn"),

    /**
     * 理财szpn
     */
    FINANCING_SZPN(40, "理财szpn"),

    /**
     * 划转SZPN
     */
    TRANSFER_SZPN(50, "划转SZPN"),

    ;

    private final Integer code;
    private final String info;

    public static UserFoundEnum of(Integer code) {
        Objects.requireNonNull(code, "类型不存在系统");
        return Stream.of(values()).filter(item -> item.code.equals(code))
            .findAny()
            .orElseThrow(() -> new IllegalArgumentException(
                String.format("%s%s", code, "类型不存在系统")
            ));
    }
}
